<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="osgi,karaf,bndtools," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="OSGi的体会我所接触到的第一个OSGi项目是Oscar，迁移到Apache基金会后，就成了现在的Apache Felix。当初的需求是为JVM中并行运行的业务链提供隔离的资源配置。看到Oscar，知道了OSGi框架规范，阅读了其代码实现，裁剪修改后用到了当时的产品之中，效果很好，于是，OSGi也就成了我持续关注的技术。
OSGi在WEB应用方面的发展，经过了这么多年，还是相对小众，主要是现有JV">
<meta property="og:type" content="article">
<meta property="og:title" content="Apache Karaf构建动态模块化应用(1)--OSGi回顾">
<meta property="og:url" content="http://chrisrc.me/2015/07/27/java-osgi-build-dynamic-app-with-karaf/index.html">
<meta property="og:site_name" content="山中，山外与俯瞰">
<meta property="og:description" content="OSGi的体会我所接触到的第一个OSGi项目是Oscar，迁移到Apache基金会后，就成了现在的Apache Felix。当初的需求是为JVM中并行运行的业务链提供隔离的资源配置。看到Oscar，知道了OSGi框架规范，阅读了其代码实现，裁剪修改后用到了当时的产品之中，效果很好，于是，OSGi也就成了我持续关注的技术。
OSGi在WEB应用方面的发展，经过了这么多年，还是相对小众，主要是现有JV">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_bigpuzzle.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_framework.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_bundle.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_classloader_1.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_classloader_2.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_classloader_3.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_bundle_lifecycle.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_blueprint.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_blueprint_service_consumer.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_blueprint_service_provider.png">
<meta property="og:updated_time" content="2016-12-17T04:03:28.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Apache Karaf构建动态模块化应用(1)--OSGi回顾">
<meta name="twitter:description" content="OSGi的体会我所接触到的第一个OSGi项目是Oscar，迁移到Apache基金会后，就成了现在的Apache Felix。当初的需求是为JVM中并行运行的业务链提供隔离的资源配置。看到Oscar，知道了OSGi框架规范，阅读了其代码实现，裁剪修改后用到了当时的产品之中，效果很好，于是，OSGi也就成了我持续关注的技术。
OSGi在WEB应用方面的发展，经过了这么多年，还是相对小众，主要是现有JV">
<meta name="twitter:image" content="http://chrisrc.me/images/java_osgi_bigpuzzle.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://chrisrc.me/2015/07/27/java-osgi-build-dynamic-app-with-karaf/"/>





  <title> Apache Karaf构建动态模块化应用(1)--OSGi回顾 | 山中，山外与俯瞰 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">山中，山外与俯瞰</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">一次永不停止的探索之旅</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-dcos">
          <a href="/dcos" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            DC/OS
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="st-search-show-outputs">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'R9GcmhBwxpsAGLNCsquZ','2.0.0');
</script>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://chrisrc.me/2015/07/27/java-osgi-build-dynamic-app-with-karaf/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="chrisrc">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="山中，山外与俯瞰">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="山中，山外与俯瞰" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Apache Karaf构建动态模块化应用(1)--OSGi回顾
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2015-07-27T09:41:27+08:00">
                2015-07-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/OSGi/" itemprop="url" rel="index">
                    <span itemprop="name">OSGi</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <a href="/2015/07/27/java-osgi-build-dynamic-app-with-karaf/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/07/27/java-osgi-build-dynamic-app-with-karaf/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="OSGi的体会"><a href="#OSGi的体会" class="headerlink" title="OSGi的体会"></a>OSGi的体会</h2><p>我所接触到的第一个OSGi项目是Oscar，迁移到Apache基金会后，就成了现在的Apache Felix。当初的需求是为JVM中并行运行的业务链提供隔离的资源配置。<br>看到Oscar，知道了OSGi框架规范，阅读了其代码实现，裁剪修改后用到了当时的产品之中，效果很好，于是，OSGi也就成了我持续关注的技术。</p>
<p>OSGi在WEB应用方面的发展，经过了这么多年，还是相对小众，主要是现有JVM ClassLoader功能的固化，J2EE体系的成熟稳定，单个Web应用系统的规模相对可控，OSGi对J2EE的工具支持相对落后，<br>众多因素导致OSGi的应用局限在J2SE级别，特别是Eclipse社区。</p>
<p>虽然OSGi的发展及应用未在企业应用端大规模普及，但OSGi在Java技术中的<strong>Jar包(bundle)层面</strong>的模块化隔离及基于接口服务的解耦机制为模块化应用开发<br>提供了一种很好的思路。当前最火爆的<strong>Docker</strong>技术，也是应用模块化及隔离技术在系统层面的一种新思路。</p>
<h2 id="OSGi的最新进展"><a href="#OSGi的最新进展" class="headerlink" title="OSGi的最新进展"></a>OSGi的最新进展</h2><ul>
<li>在关于JDK提供模块化功能中OSGi方案（JSR277/JSR291）被JCP社区（主要是Oracle）放弃后，JDK模块化系统支持方案将在<br>即将发布的下一个版本JDK9中提供（jigsaw in jdk9）。</li>
<li>OSGi技术规范及应用仍在向前推进，目前已经发布了<a href="http://www.osgi.org/Download/Release6" target="_blank" rel="external">R6版本</a>，OSGi联盟关注的重心开始<br>转向物联网IOT领域相关规范的制定与应用，希望有所突破。<br><img src="/images/java_osgi_bigpuzzle.png" alt="OSGi for IOT"></li>
<li>当前实现OSGi规范的框架主要有：<ul>
<li><a href="http://www.eclipse.org/equinox/" target="_blank" rel="external">Equinox</a> (R6)</li>
<li><a href="http://felix.apache.org/" target="_blank" rel="external">Apache Felix</a> (Oscar)  (R6)</li>
<li><a href="http://knopflerfish.org/" target="_blank" rel="external">Knopflerfish OSGi</a>  (R5)</li>
<li>Concierge (R5)</li>
<li>JBoss (R4.2)</li>
<li>ProSyst</li>
</ul>
</li>
<li>当前，OSGi规范的主推者Peter Kriens（bnd/bndtools工具的贡献者）正在致力于一个叫做<strong>OSGi enRoute</strong>的新应用框架，在这个框架中，他提出了一个<br>叫做μservice模型的概念（与最近火爆的<code>微服务</code>相对应），希望能够快速适应互联网现代应用和物联网应用的开发。关于enRoute框架可参考他的<br>文章<a href="https://jaxenter.com/osgi-enroute-a-new-framework-for-osgi-applications-117514.html" target="_blank" rel="external">OSGi enRoute – a new framework for OSGi applications</a></li>
</ul>
<h2 id="OSGi概述"><a href="#OSGi概述" class="headerlink" title="OSGi概述"></a>OSGi概述</h2><h3 id="OSGi框架"><a href="#OSGi框架" class="headerlink" title="OSGi框架"></a>OSGi框架</h3><p>从网络上搜索OSGi，大家可以看到很多介绍性的文章，了解OSGi的最好途径除了这些文章之外，下载OSGi的Release规范进行阅读是最直接的一个途径。<br>OSGi框架的结构还是要贴一下：<br><img src="/images/java_osgi_framework.png" alt="OSGi Framework"></p>
<h3 id="OSGi-Bundle"><a href="#OSGi-Bundle" class="headerlink" title="OSGi Bundle"></a>OSGi Bundle</h3><p>简单来说，OSGi框架通过JAVA ClassLoader机制在JVM内为每一个jar包提供了一个隔离的环境。这些隔离的环境想要交互必须通过Jar包内定义的MANIFEST.MF文件<br>声明环境对其他环境的依赖，环境对外暴露的资源等。OSGi用Bundle的概念封装jar，即在MANIFEST.MF中定义了OSGi标准描述符的jar。<br><img src="/images/java_osgi_bundle.png" alt="OSGi Bundle"></p>
<p>当前，大多数第三方Java项目都已经将发布包打包成了OSGi Bundle，以slf4j api包为例，我们来看一下Bundle的描述符：  </p>
<blockquote>
<p><strong>Manifest-Version:</strong> 1.0<br><strong>Archiver-Version</strong>: Plexus Archiver<br><strong>Created-By</strong>: Apache Maven<br><strong>Build-Jdk</strong>: 1.7.0_17<br><strong>Built-By</strong>: ceki<br><strong>Bundle-Description</strong>: The slf4j API<br><strong>Bundle-Version</strong>: 1.7.12<br><strong>Implementation-Version</strong>: 1.7.12<br><strong>Implementation-Title</strong>: slf4j-api<br><strong>Bundle-ManifestVersion</strong>: 2<br><strong>Bundle-SymbolicName</strong>: slf4j.api<br><strong>Bundle-Name</strong>: slf4j-api<br><strong>Bundle-Vendor</strong>: SLF4J.ORG<br><strong>Bundle-RequiredExecutionEnvironment</strong>: J2SE-1.5<br><strong>Export-Package</strong>: org.slf4j;version=1.7.12,   org.slf4j.spi;version=1.7.12<br>, org.slf4j.helpers;version=1.7.12<br><strong>Import-Package</strong>: org.slf4j.impl;version=1.6.0</p>
</blockquote>
<p><code>Bundle-SymbolicName</code> 和 <code>Bundle-Version</code> 唯一标识这个jar包; <code>Export-Package</code> 向外部环境公开资源，即那些package可以被访问;<br><code>Import-Package</code>说明这个Bundle要正常使用需要哪些外部环境就绪。</p>
<h3 id="OSGi类加载"><a href="#OSGi类加载" class="headerlink" title="OSGi类加载"></a>OSGi类加载</h3><p>JAVA中Package及类的隔离需要通过类加载器ClassLoader实现，通常的Java应用中一个类加载器加载所有应用及依赖类包，如下图所示：<br><img src="/images/java_osgi_classloader_1.png" alt="传统类加载"></p>
<p>在OSGi中，框架为每个bundle构建一个独立的类加载器，来限定jar包的访问边界。这些类加载器共享OSGi框架（System Bundle）的类加载器：<br><img src="/images/java_osgi_classloader_2.png" alt="OSGi类加载"></p>
<p>在这种模式下，每一个Bundle都有了一个自己的类域，每个Bundle只能看到框架公布的类资源，内部的类资源以及通过Import-Package声明引入<br>的其他类资源。<br><img src="/images/java_osgi_classloader_3.png" alt="OSGi Bundle类域"></p>
<h3 id="OSGi-Bundle开发基础"><a href="#OSGi-Bundle开发基础" class="headerlink" title="OSGi Bundle开发基础"></a>OSGi Bundle开发基础</h3><p>在OSGi中每一个Bundle都是隔离可控的，因此，OSGi框架可以很容易的控制Bundle的生命周期：<br><img src="/images/java_osgi_bundle_lifecycle.png" alt="Bundle生命周期"></p>
<p>通过Bundle生命周期控制，我们可以很容易的实现Bundle的动态加载和卸载，实现热替换。</p>
<p>OSGi框架为Bundle开发提供了标准的接口，如BundleActivator接口可以控制Bundle的启动和停止，*Listener接口可以监听框架、Bundle及服务<br>事件并做出响应等：</p>
<ul>
<li>Bundle Activator</li>
<li>提供一个服务</li>
<li>调用一个服务</li>
<li>使用FrameworkListener 监听框架事件</li>
<li>使用BundleListener监听Bundle生命周期事件</li>
<li>使用ServiceListener 监听服务的变化</li>
<li>使用ServiceFactory 动态创建服务</li>
<li>使用ServiceTracker 跟踪服务</li>
<li>使用filters过滤服务</li>
</ul>
<p>在进行OSGi开发时，必须熟悉上述基础开发，才能理解OSGi的动态特性。但是，所有的功能都从这些基础做起，系统的开发将变得非常繁琐和复杂，<br>这也是由于OSGi的动态特性所导致的，因为在OSGi中，Bundle、Service、Config等一切都是动态的，以Service为例：</p>
<ul>
<li>服务可能还没就绪</li>
<li>服务可能已经停止了</li>
<li>服务可能存在多个</li>
<li>服务可能失败</li>
</ul>
<p>为每个服务考虑上述动态特性，代码将变得非常复杂。此时，需要借助一个编程实践和框架来简化开发，让开发人员享受动态优势的同时，又能<br>专注于思考业务实现，如：</p>
<ul>
<li>Felix Dependency Manager</li>
<li>Service Component Runtime (SCR)</li>
<li>Apache Aries Blueprint</li>
</ul>
<p><strong>Service Component Runtime （SCR）</strong>  </p>
<p>最新的SCR服务已经支持通过注解的方式生命服务和引用，这极大的简化了在动态Bundle中对动态Service的维护。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">Speak</span> </span>&#123; <span class="function"><span class="keyword">void</span> <span class="title">say</span><span class="params">(String text)</span></span>; &#125;</div><div class="line"></div><div class="line"><span class="meta">@Component</span></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SpeakLogImpl</span> <span class="keyword">implements</span> <span class="title">Speak</span> </span>&#123;</div><div class="line"></div><div class="line">    Logger logger;</div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">say</span><span class="params">(String text)</span> </span>&#123;</div><div class="line"></div><div class="line">      logger.info(text);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="meta">@Reference</span></div><div class="line">    <span class="function"><span class="keyword">void</span> <span class="title">setLog</span><span class="params">( Logger log)</span> </span>&#123; <span class="keyword">this</span>.logger = log; &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>对于如何使用SCR注解，请参考<a href="http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html" target="_blank" rel="external">SCR Annotations</a></p>
<p><strong>Apache Aries Blueprint （Blueprint）</strong>  </p>
<p>OSGi Blueprint规范是在Spring的基础上发展来的，它将Spring对Bean的管理移植到了OSGi环境下。<br><img src="/images/java_osgi_blueprint.png" alt="OSGi Blueprint"></p>
<p>在一个Bundle中，Blueprint的xml配置位于<strong>OSGI-INF/blueprnt/</strong> 目录下，xml的文件名可以根据需要定义。</p>
<p>下面是一个服务引用者Bundle的Blueprint配置文件示例：<br><img src="/images/java_osgi_blueprint_service_consumer.png" alt="Blueprint Service Consumer"><br>下面是一个服务发布者Bundle的Blueprint配置文件示例：<br><img src="/images/java_osgi_blueprint_service_provider.png" alt="Blueprint Service Consumer"></p>
<h2 id="OSGi-Bundle开发工具"><a href="#OSGi-Bundle开发工具" class="headerlink" title="OSGi Bundle开发工具"></a>OSGi Bundle开发工具</h2><p>当前，主流IDE环境都对OSGi开发提供了支持：  </p>
<ul>
<li>Eclipse Plugin Development</li>
<li>BndTools Plugin</li>
<li>Maven Bundle Plugin</li>
<li>BndTools Maven Plugin (New)</li>
<li>Netbeans Maven OSGi</li>
<li>Jetbrains IDEA Osmorc</li>
</ul>
<p>在这些开发工具中，<strong>BndTools</strong> 和 <strong>Maven Bundle Plugin</strong> 最为方便。 BndTools Maven Plugin是Maven Bundle Plugin的替代者。</p>
<h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><ul>
<li>当前随着移动互联网，物联网的快速发展，大数据，分布式和运计算等新的技术在不断出现，心的技术不再局限于单一语言平台，往往需要众多异构<br>系统紧密协作。OSGi如何适应这些新兴需求，我们将持续关注,感兴趣的可以查看<a href="https://github.com/osgi/design" target="_blank" rel="external">OSGi RFP/RFC文档</a>。</li>
<li>在OSGi系列的下一篇文章，我们将通过BndTools工具讲述如何快速简单的进行OSGi Bundle开发。</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/osgi/" rel="tag"># osgi</a>
          
            <a href="/tags/karaf/" rel="tag"># karaf</a>
          
            <a href="/tags/bndtools/" rel="tag"># bndtools</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/06/07/java-jni-with_swig/" rel="next" title="使用Swig封装DLL实现JNI快速开发">
                <i class="fa fa-chevron-left"></i> 使用Swig封装DLL实现JNI快速开发
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/07/29/java-osgi-dynamic-app-with-karaf-bndtools/" rel="prev" title="Apache Karaf构建动态模块化应用(2)--使用Bndtools开发Bundle">
                Apache Karaf构建动态模块化应用(2)--使用Bndtools开发Bundle <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2015/07/27/java-osgi-build-dynamic-app-with-karaf/"
     data-title="Apache Karaf构建动态模块化应用(1)--OSGi回顾"
     data-content=""
     data-url="http://chrisrc.me/2015/07/27/java-osgi-build-dynamic-app-with-karaf/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/07/27/java-osgi-build-dynamic-app-with-karaf/"
           data-title="Apache Karaf构建动态模块化应用(1)--OSGi回顾" data-url="http://chrisrc.me/2015/07/27/java-osgi-build-dynamic-app-with-karaf/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="chrisrc" />
          <p class="site-author-name" itemprop="name">chrisrc</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">69</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">21</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">162</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/christtrc" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/chrisrc" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#OSGi的体会"><span class="nav-number">1.</span> <span class="nav-text">OSGi的体会</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#OSGi的最新进展"><span class="nav-number">2.</span> <span class="nav-text">OSGi的最新进展</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#OSGi概述"><span class="nav-number">3.</span> <span class="nav-text">OSGi概述</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#OSGi框架"><span class="nav-number">3.1.</span> <span class="nav-text">OSGi框架</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#OSGi-Bundle"><span class="nav-number">3.2.</span> <span class="nav-text">OSGi Bundle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#OSGi类加载"><span class="nav-number">3.3.</span> <span class="nav-text">OSGi类加载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#OSGi-Bundle开发基础"><span class="nav-number">3.4.</span> <span class="nav-text">OSGi Bundle开发基础</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#OSGi-Bundle开发工具"><span class="nav-number">4.</span> <span class="nav-text">OSGi Bundle开发工具</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#结论"><span class="nav-number">5.</span> <span class="nav-text">结论</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">
     
      <a href="mailto:chrisrc@qq.com">chrisrc</a> 
    
  </span>
  <span class="author"> &nbsp; QQ: 58122705 </span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"chrisrc"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  








  
  

  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
<script>
(function(){
   var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04":"https://jspassport.ssl.qhimg.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04";
   document.write('<script src="' + src + '" id="sozz"><\/script>');
})();
</script>

  


</body>
</html>
